//
//  APBaseNavigationController.swift
//  APSwift
//
//  Created by jianbo.pei on 2023/3/29.
//

import UIKit

open class APBaseNavigationController: UINavigationController {

    open override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

}


extension APBaseNavigationController {
    /// （如果需要的话）重置`viewControllers`
    public func resetViewControllersIfNeeded() {
        guard viewControllers.count > 0 else {
            return
        }
        var wantedVCs: [UIViewController] = []
        for viewController in viewControllers {
            guard let vc = viewController as? APBaseViewController else { return }
            guard !vc.deinitAfterPush else { return }
            wantedVCs.append(vc)
        }
        if wantedVCs.count != viewControllers.count {
            viewControllers = wantedVCs
        }
    }
}
